#!/usr/bin/python
import re 

__author__ = 'meirdrago'

#	Extract contents of row of columns in KEY=VAL pattern
#	
#	Example : 
#	INPUT :
#	'2013-12-17 23:06:49 err=no-query-string a= ir= uref= icid= cc=ru p=foxtab h=search.foxtab.com b=Firefox bv=4.0b13pre iv= uid= f= ip=31.148.246.53 cd= cr='
#
#	OUTPUT :
#	{err:"no-query-string" , a:"" , ir:"" , uref:"" , icid:"" , cc:"ru" , p:"foxtab" ... }

class Parser:
	regex 	= None
	def __init__(self):
		self.regex 	= re.compile(r'(\S+?)=(\S*)')

	def do_parse(self,line):
		res   = {}
		parts = self.regex.findall(line)
		if len(parts) > 0:
			for i in parts:
				res[i[0]] = i[1]
		return res


